package juc.producerandconsumer;

public class ProducerAndConsumer {
    public static void main(String[] args) {
        Buffer buffer = new Buffer(6);
        // 创建多个消费者线程
        for (int i = 0; i < 3; i++) {
            new Thread(() -> {
                while (true) {
                    buffer.get();
                }
            }, "consumer-" + i).start();
        }
        // 创建多个生产者线程
        for (int i = 0; i < 3; i++) {
            new Thread(() -> {
                while (true) {
                    buffer.put();
                }
            }, "producer-" + i).start();
        }
    }
}
